import fs from 'node:fs';
import path from 'path';

class XdxzData {
	constructor() {
		this.filePathMap = {
			lib: path.join(path.resolve(), 'plugins', 'xdxz', 'data')
		};
		this.lib_path = this.filePathMap.lib;
        //加载超市商品列表
		this.cs_list = JSON.parse(
			fs.readFileSync(`${this.lib_path}/chaoshi.json`)
		);
        //加载网吧随机事件文件
		this.wb_list = JSON.parse(
			fs.readFileSync(`${this.lib_path}/wangba.json`)
		);
        //加载游泳随机事件文件
		this.yy_list = JSON.parse(
			fs.readFileSync(`${this.lib_path}/youyong.json`)
		);
        //加载小镇人才市场json文件
		this.rcsc_list = JSON.parse(
			fs.readFileSync(`${this.lib_path}/rencai.json`)
		);
    }
    /**
	 * 检测存档存在
	 * @param file_path_type ["player" , "association" ]
	 * @param file_name
	 */
	existData(file_path_type, file_name) {
		let file_path;
		file_path = this.filePathMap[file_path_type];
		let dir = path.join(file_path + '/' + file_name + '.json');
		if (fs.existsSync(dir)) {
			return true;
		}
		return false;
	}
}
export default new XdxzData();